package com.jzo2o.customer.controller.operation;

import cn.hutool.core.bean.BeanUtil;
import com.jzo2o.common.model.PageResult;
import com.jzo2o.common.model.Result;
import com.jzo2o.customer.model.dto.request.AuditWorkReqDto;
import com.jzo2o.customer.model.dto.request.InstitutionPageQueryParamsDTO;
import com.jzo2o.customer.model.dto.response.CertificationInfoDTO;
import com.jzo2o.customer.model.dto.response.InstitutionCertificationAuditRespDTO;
import com.jzo2o.customer.model.dto.response.WorkerCertificationResDTO;
import com.jzo2o.customer.model.page.CertificationQueryPageParams;
import com.jzo2o.customer.service.IAgencyCertificationService;
import com.jzo2o.customer.service.IWorkerCertificationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author itcast
 */
@RestController("operationWorkerCertificationController")
@RequestMapping("/operation")
@Api(tags = "运营端 - 服务人员认证信息相关接口")
public class WorkerCertificationController {

    @Resource
    private IWorkerCertificationService workerCertificationService;
    @Resource
    private IAgencyCertificationService agencyCertificationService;

    @GetMapping("/worker-certification/{id}")
    @ApiOperation("根据服务人员id查询认证信息")
    public WorkerCertificationResDTO queryById(@PathVariable("id") Long id) {
        return BeanUtil.toBean(workerCertificationService.getById(id), WorkerCertificationResDTO.class);
    }
    @GetMapping("/worker-certification-audit/page")
    @ApiOperation("审核服务人员认证分页查询")
    public PageResult<CertificationInfoDTO> page( CertificationQueryPageParams certificationQueryPageParams ) {
    return workerCertificationService.pageQueryAgency(certificationQueryPageParams);
    }
    @PutMapping("/worker-certification-audit/audit/{id}")
    @ApiOperation("审核服务人员认证信息")
    public Result auditWork(@PathVariable("id") Long id, AuditWorkReqDto auditWorkReqDto) {
        workerCertificationService.auditWork(id, auditWorkReqDto);
        return Result.ok();
    }
    @GetMapping("/agency-certification-audit/page")
    @ApiOperation("审核机构人员认证分页查询")
    public PageResult<InstitutionCertificationAuditRespDTO> page(InstitutionPageQueryParamsDTO institutionStaffPageQueryReqDTO) {
        return agencyCertificationService.pageQueryAgency(institutionStaffPageQueryReqDTO);
    }
    @PutMapping("agency-certification-audit/audit/{id}")
    @ApiOperation("审核机构人员")
    public Result auditInstitution(@PathVariable("id") Long id, AuditWorkReqDto auditWorkReqDto) {
         agencyCertificationService.auditInstitution(id, auditWorkReqDto);
         return Result.ok();
    }
}
